
// if (window.location.host == 'idaxue.taobao.com') {
//     if (window.location.pathname == '/play.jhtml') {

        let port = chrome.extension.connect({name: new Date().getTime() + ''});
        port.onMessage.addListener(function(msg) {
            // console.log('收到background的消息:' + JSON.stringify(msg))
            sendMsgToInject(msg.name, msg.data);
        });

        function sendMsgToBackground(name, data) {
            port.postMessage({
                name: name,
                data: data ? data : {}
            });
        }

        window.addEventListener("message", function(event) {
            if (event.source != window)
                return;
            if (event.data.from && (event.data.from == "FROM_PAGE")) {
                sendMsgToBackground(event.data.name, event.data.data);
            }
        });

        // 发送消息给html5
        function sendMsgToInject(name, data) {
            let message = {
                name: name,
                data: data ? data : {},
                from: 'FROM_CONTENT_SCRIPT'
            }
            window.postMessage(message, "*");
        }

        InjectHelper.addInjectScript("MsgDef.js")
        InjectHelper.addInjectScript("injects/main.js")
        InjectHelper.addInjectCss("injects/main.css")
//     }
// }


